﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Forum.Entity.Post;
using Forum.DAL.Post;
using Frame.Lib.Web;
using Frame.Lib.Core.Base;
using Forum.BLL.Board;
using Forum.Entity.Board;

namespace Forum.BLL.Post
{
    public class TopicBO : CommonOperate<TopicInfo>
    {
        private TopicDAL _forumTopic;
        protected override BaseDAL DAL
        {
            get
            {
                return _forumTopic;

            }
        }
        public TopicBO()
        {
            _forumTopic = new TopicDAL();
        }


        /// <summary>
        /// 获取本版非置顶贴（审核通过的）
        /// </summary>
        /// <param name="boardID"></param>
        /// <returns></returns>
        public List<TopicInfo> GetNormalList(int boardID, int typeID, PagerSetting pager)
        {
            pager.Where = " BoardID=@p0 and TopLevel=0 and IsDisplay=1 ";
            if (typeID != 0)
            {
                pager.Where += " and TypeID=@p1";
            }
            pager.OrderBy = " LastPostTime desc ";
            List<TopicInfo> list = base.GetList(pager, boardID, typeID);
            return list;
        }

        /// <summary>
        /// 获取置顶贴，包括全局置顶和版块置顶
        /// </summary>
        /// <param name="boardID"></param>
        /// <returns></returns>
        public List<TopicInfo> GetTopList(int boardID)
        {
            List<TopicInfo> list = _forumTopic.GetTopList(boardID);
            return list;
        }

        public override TopicInfo GetInfo(object id)
        {
            TopicInfo info = base.GetInfo(id);
            info.GetBoardInfo = boardID =>
            {
                BoardInfo bInfo = new BoardBO().GetInfo(boardID);
                return bInfo;
            };
            return info;
        }
    }
}
